/*
* @desc:工具常用打印方法
* @company:KBS
* @Author: TommySUN
* @Date:   2022/11/02 22:16
 */

package gotlib

import (
	"fmt"

	"gitee.com/tommickey/gose/v3/gose/gotconst"
)

func PrintNormal(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Print(s)
}
func PrintNormalLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Println(s)
}
func PrintNormalF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintNormal(s)
	return s
}

func PrintBlack(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.BlackColorPrint, 0x1B, s, 0x1B)
}
func PrintBlackLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.BlackColorPrintLn, 0x1B, s, 0x1B)
}
func PrintBlackF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintBlack(s)
	return s
}

func PrintRed(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.RedColorPrint, 0x1B, s, 0x1B)
}
func PrintRedLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.RedColorPrintLn, 0x1B, s, 0x1B)
}
func PrintRedF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintRed(s)
	return s
}

func PrintGreen(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.GreenColorPrint, 0x1B, s, 0x1B)
}
func PrintGreenLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.GreenColorPrintLn, 0x1B, s, 0x1B)
}
func PrintGreenF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintGreen(s)
	return s
}

func PrintYellow(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.YellowColorPrint, 0x1B, s, 0x1B)
}
func PrintYellowLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.YellowColorPrintLn, 0x1B, s, 0x1B)
}
func PrintYellowF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintYellow(s)
	return s
}

func PrintBlue(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.BlueColorPrint, 0x1B, s, 0x1B)
}
func PrintBlueLn(a ...interface{}) {
	s := ArrayToString(a...)
	fmt.Printf(gotconst.BlueColorPrintLn, 0x1B, s, 0x1B)
}
func PrintBlueF(format string, a ...interface{}) string {
	s := fmt.Sprintf(format, a...)
	PrintBlue(s)
	return s
}

func PrintLoopAll() {
	// 前景 背景 颜色
	// 30  40  黑色
	// 31  41  红色
	// 32  42  绿色
	// 33  43  黄色
	// 34  44  蓝色
	// 35  45  紫红色
	// 36  46  青蓝色
	// 37  47  白色

	// 代码 意义
	//  0  终端默认设置
	//  1  高亮显示
	//  4  使用下划线
	//  5  闪烁
	//  7  反白显示
	//  8  不可见

	for b := 40; b <= 47; b++ { // 背景色彩 = 40-47
		for f := 30; f <= 37; f++ { // 前景色彩 = 30-37
			for d := range []int{0, 1, 4, 5, 7, 8} { // 显示方式 = 0,1,4,5,7,8
				fmt.Printf(" %c[%d;%d;%dm%s(f=%d,b=%d,d=%d)%c[0m ", 0x1B, d, b, f, "", f, b, d, 0x1B)
			}
			fmt.Println("")
		}
		fmt.Println("")
	}
}
